<template>
  <div>
    <div id="pie" style="width: 500px; height: 400px"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pieData: [
        { value: 1048, name: "Search Engine" },
        { value: 735, name: "Direct" },
        { value: 580, name: "Email" },
        { value: 484, name: "Union Ads" },
        { value: 300, name: "Video Ads" },
      ],
    };
  },
  methods: {
    pieChart() {
      var myChart = this.$echarts.init(document.getElementById("pie"));
      myChart.setOption({
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "5%",
          left: "center",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: "#fff",
              borderWidth: 2,
            },
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: this.pieData,
          },
        ],
      });
    },
  },
  mounted() {
    this.pieChart();
  },
};
</script>

<style lang="scss" scoped>
</style>